﻿using King.Box.Models.Db.Sys;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;

namespace King.Box.DbProvider
{
    public class DalContext<T> : DbContext where T : class
    {
        public DalContext() { }

        public DalContext(string conn) : base(conn)
        {
            this.Configuration.AutoDetectChangesEnabled = true;
            this.Configuration.LazyLoadingEnabled = true;
        }

        public DbSet<T> Provider { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        }
    }
}
